<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui">
	<ui:composition template="/templates/padrao.xhtml">
		<ui:define name="barraTitulo">Cadastro de Processo</ui:define>
		<ui:define name="conteudo">
			<h:form id="form">
				<p:growl id="messages" />
				<p:tabView id="divTabView">
					<p:tab title="Cadastro">
						<h:panelGrid columns="2" columnClasses="width150 alinhaDir, width500">

							<h:column >
							</h:column>
							<h:column >
							</h:column>
							
							<h:column >
								<h:outputText value="N&uacute;mero do Processo:" styleClass=""/>
							</h:column>
							<h:column >
								<h:inputText  value="#{controleProcesso.processo.numeroProcesso}" size="30" maxlength="50" requiredMessage="Campo [N&Uacute;MERO PROCESSO] obrigat&oacute;rio"/>
								<h:outputText value="Pasta:" styleClass=""/>&nbsp;
								<h:inputText  value="#{controleProcesso.processo.pasta}" size="10" maxlength="10"/>
								<h:outputText value="Valor:" styleClass=""/>&nbsp;
								<h:inputText name="valor" type="text" class="textfield" required="true" id="valor" size="10" value="#{controleProcesso.processo.valor}" alt="decimal" >
										<f:convertNumber type="currency" pattern="#,##0.00" />
								</h:inputText>
								<h:outputText value="LitisCons&oacute;rcio:" />&nbsp;
								<h:selectBooleanCheckbox value="#{controleProcesso.processo.litisConsorcio}" />&nbsp;
							</h:column>
							<h:column >
								<h:outputText value="Comarca:" styleClass="select" />
							</h:column>
							<h:column >
								<h:selectOneMenu value="#{controleProcesso.processo.comarca}" >  
								    <f:selectItem itemLabel="selecione" itemValue="#{controleProcesso.comarcaSelecione}"/>
				                    <f:selectItems value="#{controleProcesso.comarcas}" var="comarca" itemLabel="#{comarca.descricao}" itemValue="#{comarca}"/>
				                    <f:converter converterId="comarcaConverte"/>
								</h:selectOneMenu>
							</h:column>
							<h:column >
								<h:outputText value="&Aacute;rea:" styleClass="select" />
							</h:column>
							<h:column >
								<h:selectOneMenu value="#{controleProcesso.processo.area}" >  
								    <f:selectItem itemLabel="selecione" itemValue="#{controleProcesso.areaSelecione}"/>
				                    <f:selectItems value="#{controleProcesso.areas}" var="area" itemLabel="#{area.descricao}" itemValue="#{area}"/>
				                    <f:converter converterId="areaConverte"/>
								</h:selectOneMenu>
							</h:column>
							<h:column >
								<h:outputText value="Vara:" styleClass="select" />
							</h:column>
							<h:column >
								<h:selectOneMenu value="#{controleProcesso.processo.vara}" >  
								    <f:selectItem itemLabel="selecione" itemValue="#{controleProcesso.varaSelecione}"/>
				                    <f:selectItems value="#{controleProcesso.varas}" var="vara" itemLabel="#{vara.descricao}" itemValue="#{vara}"/>
				                    <f:converter converterId="varaConverte"/>
								</h:selectOneMenu>
							</h:column>
							<h:column >
								<h:outputText value="A&ccedil;&atilde;o:" styleClass="select" />
							</h:column>
							<h:column >
								<h:selectOneMenu value="#{controleProcesso.processo.acao}" > 
									<f:selectItem itemLabel="selecione" itemValue="#{controleProcesso.acaoSelecione}"/>
				                    <f:selectItems value="#{controleProcesso.acoes}" var="acao" itemLabel="#{acao.descricao}" itemValue="#{acao}"/>
				                    <f:converter converterId="acaoConverte"/>
								</h:selectOneMenu>
							</h:column>
							<h:column >
								<h:outputText value="Autor:" styleClass="select" />
							</h:column>
							<h:column >
								<h:selectOneMenu value="#{controleProcesso.processo.autor}" >  
									<f:selectItem itemLabel="selecione" itemValue="#{controleProcesso.autorSelecione}"/>
				                    <f:selectItems value="#{controleProcesso.autores}" var="autor" itemLabel="#{autor.pessoa.nome}" itemValue="#{autor}"/>
				                    <f:converter converterId="autorConverte"/>
								</h:selectOneMenu>
								<h:commandLink action="#{controleAutor.adicionar}">
									<h:graphicImage url="/images/marcadores/add.png" class="btnAcoes"/>
									<f:setPropertyActionListener target="#{controleAutor.fromProcesso}" value="true"></f:setPropertyActionListener>
								</h:commandLink>
							</h:column>
							<h:column >
								<h:outputText value="R&eacute;u:" styleClass="select" />
							</h:column>
							<h:column >
								<h:selectOneMenu value="#{controleProcesso.processo.reu}" >  
									<f:selectItem itemLabel="selecione" itemValue="#{controleProcesso.reuSelecione}"/>
				                    <f:selectItems value="#{controleProcesso.reus}" var="reu" itemLabel="#{reu.pessoa.nome}" itemValue="#{reu}"/>
				                    <f:converter converterId="reuConverte"/>
								</h:selectOneMenu>
								<h:commandLink action="#{controleReu.adicionar}">
									<h:graphicImage url="/images/marcadores/add.png" class="btnAcoes"/>
									<f:setPropertyActionListener target="#{controleReu.fromProcesso}" value="true"></f:setPropertyActionListener>
								</h:commandLink>
							</h:column>
							<h:column >
								<h:outputText value="Advogado Autor:" styleClass="select" />
							</h:column>
							<h:column >
								<h:selectOneMenu value="#{controleProcesso.processo.advogadoAutor}" >  
									<f:selectItem itemLabel="selecione" itemValue="#{controleProcesso.advogadoAutorSelecione}"/>
				                    <f:selectItems value="#{controleProcesso.advogadoAutores}" var="advogado" itemLabel="#{advogado.pessoa.nome}" itemValue="#{advogado}"/>
				                    <f:converter converterId="advogadoConverte"/>
								</h:selectOneMenu>
								<h:commandLink action="#{controleAdvogado.adicionar}">
									<h:graphicImage url="/images/marcadores/add.png" class="btnAcoes"/>
									<f:setPropertyActionListener target="#{controleAdvogado.fromProcesso}" value="true"></f:setPropertyActionListener>
								</h:commandLink>
							</h:column>
							<h:column >
								<h:outputText value="Advogado R&eacute;u:" styleClass="select" />
							</h:column>
							<h:column >
								<h:selectOneMenu value="#{controleProcesso.processo.advogadoReu}" >  
									<f:selectItem itemLabel="selecione" itemValue="#{controleProcesso.advogadoReuSelecione}"/>
				                    <f:selectItems value="#{controleProcesso.advogadoReus}" var="advogado" itemLabel="#{advogado.pessoa.nome}" itemValue="#{advogado}"/>
				                    <f:converter converterId="advogadoConverte"/>
								</h:selectOneMenu>
								<h:commandLink action="#{controleAdvogado.adicionar}">
									<h:graphicImage url="/images/marcadores/add.png" class="btnAcoes"/>
									<f:setPropertyActionListener target="#{controleAdvogado.fromProcesso}" value="true"></f:setPropertyActionListener>
								</h:commandLink>
							</h:column>
							
							<h:column >
								<h:outputText value="Data:"/>
							</h:column>
							<h:column>
								<p:calendar value="#{controleProcesso.processo.dataEntrada}" mode="popup" pattern="dd/MM/yyyy" requiredMessage="Campo [DATA] obrigat&oacute;rio" />
								&nbsp;
								<h:outputText value="Hora:"/>
								&nbsp;
								<p:inputMask value="#{controleProcesso.processo.horaEntrada}" mask="99:99" size="5" maxlength="5" requiredMessage="Campo [HORA] obrigat&oacute;rio"/>
								&nbsp;
								<h:outputText value="Ajuizamento:"/>
								<p:calendar value="#{controleProcesso.processo.dataAjuizamento}" mode="popup" pattern="dd/MM/yyyy" requiredMessage="Campo [DATA] obrigat&oacute;rio" />
								
							</h:column>
							
							
							<h:column />
							<p:fileUpload fileUploadListener="#{controleProcesso.fileUpload}" auto="true"   
     							multiple="true" label="Anexo(s)" allowTypes="*.jpg;*.png;*.gif;*.docx;*.doc;*.txt;*.xls;*.xlsx;*.pdf" description="" update="id_panelAnexo"/>
							<h:column />
							<p:panel id="id_panelAnexo">
								<h:panelGrid columns="1" >
									<p:dataTable value="#{controleProcesso.processo.anexos}" 
									             id="id_ListaAnexo"
									             var="anexo" 
									             paginator="false" 
									             selectionMode="single"
									             dynamic="true"
									             rendered="#{not empty controleProcesso.processo.anexos}">
										<p:column sortBy="#{anexo.descricao}">
											<f:facet name="header">
												<h:outputText value="Nome Arquivo" />
											</f:facet>
											<h:outputText value="#{anexo.descricao}" />
										</p:column>
										<p:column styleClass="width40">
											<f:facet name="header">
												<h:outputText value="A&ccedil;&atilde;o" />
											</f:facet>
											<h:commandLink action="#{controleProcesso.abrirAnexo}">
												<h:graphicImage url="/images/marcadores/abrir.png" alt="adicionar Destinat&aacute;rio"/>
												<f:setPropertyActionListener target="#{controleProcesso.anexo}" value="#{anexo}"/>
											</h:commandLink>
											<h:commandLink action="#{controleProcesso.delAnexo}">
												<h:graphicImage url="/images/marcadores/erro.png" alt="adicionar Destinat&aacute;rio"/>
												<f:setPropertyActionListener target="#{controleProcesso.anexo}" value="#{anexo}"/>
											</h:commandLink>
				                    		</p:column>
									</p:dataTable>
								</h:panelGrid>
							</p:panel>
							
							
						</h:panelGrid>
					</p:tab>
				</p:tabView>
				<p:tabView id="divTabViewFases">
					<p:tab title="Fases">
						<h:panelGrid columns="2" columnClasses="width150 alinhaDir, width500">
							<h:column >
								<h:outputText value="Fases" styleClass="select" />
							</h:column>
							<h:column >
								<h:selectOneMenu value="#{controleProcesso.fase}" >  
				                    <f:selectItems value="#{controleProcesso.fases}" var="fase" itemLabel="#{fase.descricao}" itemValue="#{fase}"/>
				                    <f:converter converterId="faseConverte"/>
				                    <f:ajax execute="@form"/>
								</h:selectOneMenu>
							</h:column>
							<h:column >
								<h:outputText value="Data / Hora:"/>
							</h:column>
							<h:column>
								<p:calendar value="#{controleProcesso.data}" mode="popup" pattern="dd/MM/yyyy" requiredMessage="Campo [DATA] obrigat&oacute;rio" />
								&nbsp;
								<p:inputMask value="#{controleProcesso.hora}" mask="99:99" size="5" maxlength="5" requiredMessage="Campo [HORA] obrigat&oacute;rio"/>
							</h:column>
							
							<h:commandLink action="#{controleProcesso.addFase}" styleClass="alinhaDir">
								<h:graphicImage url="/images/botoes/btnAdicionar.png" class="btnAcoes"/>
							</h:commandLink>							
													
						</h:panelGrid>
						
						<p:dataTable value="#{controleProcesso.processo.processoFases}" 
						             id="id_ListaProcessoFases"
						             var="processoFase" 
						             paginator="true" 
						             rows="10" 
						             dynamic="true" 
						             rendered="#{not empty controleProcesso.processo.processoFases}" 
									 firstPageLinkLabel="Primeiro"
						             previousPageLinkLabel="Anterior"
						             nextPageLinkLabel ="Pr&oacute;ximo"
						             lastPageLinkLabel="&Uacute;ltima"
						             emptyMessage="Nenhum resgistro encontrado"
						             errorMessage="Ocorreu um erro"
		    			              
						             selectionMode="single">
						             
							<p:column>
								<f:facet name="header">
									<h:outputText value="Fase" />
								</f:facet>
								<h:outputText value="#{processoFase.fase.descricao}" />
							</p:column>

							<p:column styleClass="width30" >
								<f:facet name="header">
									<h:outputText value="Data" />
								</f:facet>
								<h:outputText value="#{processoFase.data}">
									<f:convertDateTime pattern="dd/MM/yyyy" />
								</h:outputText>
							</p:column>
							
							<p:column styleClass="width30" >
								<f:facet name="header">
									<h:outputText value="Hora" />
								</f:facet>
								<h:outputText value="#{processoFase.hora}"/>
							</p:column>
							
							<p:column resizable="true" styleClass="width80">
								<f:facet name="header">
									<h:outputText value="A&ccedil;&atilde;o" /> 
								</f:facet>
								<p:commandLink update="id_ListaProcessoFases" oncomplete="dlg.show();">  
									<h:graphicImage url="/images/marcadores/excluir.png" alt="Excluir Fase"/>  
									<f:setPropertyActionListener target="#{controleProcesso.processoFase}" value="#{processoFase}" />
								</p:commandLink>
	                     	</p:column>
						</p:dataTable>
						<p:dialog header="Confirma&ccedil;&atilde;o" width="300" fixedCenter="true" widgetVar="dlg" visible="false">  
							<h:panelGrid columns="2" style="margin-bottom:10px">
								<h:column>   
									<h:outputLabel  value="Deseja Excluir?" />
								</h:column>
								<h:column >
									<p:commandButton value="Sim" action="#{controleProcesso.delFase}" update="id_ListaProcessoFases" oncomplete="dlg.hide();" />  
									<p:commandButton value="Nao" update="form" oncomplete="dlg.hide();"/>
								</h:column>  
							</h:panelGrid>  
						</p:dialog>
						
						
						
					</p:tab>
				</p:tabView>
				
				
				<h:outputLink value="manutencao.jsf">
					<h:graphicImage url="/images/botoes/btnPesquisar.png" class="btnAcoes"/>
				</h:outputLink>
				<h:commandLink action="#{controleProcesso.gravar}" styleClass="alinhaDir">
					<h:graphicImage url="/images/botoes/btnGravar.png" class="btnAcoes"/>
				</h:commandLink>
			</h:form>
		</ui:define>
	</ui:composition>
</html>